package com.wing.cabinet.model.response;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.wing.cabinet.model.entity.CabinetCargoSpace;
import com.wing.cabinet.model.entity.StorageInventorySpace;
import com.wing.cabinet.utils.ExcelExport;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 暂存柜产品货道库存VO
 *
 * @author
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
public class StorageInventorySpaceVO implements Comparable<StorageInventorySpaceVO>{

    /**
     * ID
     */
    private Long id;

    /**
     * 创建时间
     */
    @JsonFormat(timezone = "GMT+8" , pattern = "yyyy-MM-dd HH:mm:ss" )
    private LocalDateTime createTime;

    /**
     * 创建者
     */
    private Long creator;

    /**
     * 修改者
     */
    private Long modifier;

    /**
     * 创建人
     */
    private String creatorName;

    /**
     * 修改人
     */
    private String modifierName;

    /**
     * 柜子id
     */
    private Long cabId;

    /**
     * 柜子编号
     */
    @ExcelExport(value = "柜子编号",sort = 50)
    private String cabCode;

    /**
     * 货道id
     */
    private Long spaceId;

    /**
     * 货道编号
     */
    @ExcelExport(value = "库位编号",sort = 60)
    private String spaceCode;

    /**
     * sku id
     */
    private Long skuId;

    /**
     * sku 编号
     */
    @ExcelExport(value = "物料编号",sort = 20)
    private String skuCode;

    /**
     * 库存数量
     */
    @ExcelExport(value = "数量（包装计）",sort = 80)
    private Integer quantity;

    @ExcelExport(value = "存入类型",sort = 70,kv = "temp-暂存;repair-报修;recycle-回收")
    private StorageInventorySpace.BusinessType businessType;

    private String businessTypeDesc;

    public String getBusinessTypeDesc(){
        if (this.businessType!=null){
            return businessType.getDesc();
        }
        return "";
    }


    /**
     * sku 名称
     */
    @ExcelExport(value = "物料名称",sort = 10)
    private String skuName;

    /**
     * sku 规格
     */
    private String skuSpec;

    /**
     * sku 图片
     */
    private String skuPic;

    /**
     * 产品名称
     */
    private String productName;

    /**
     * 产品类型名称
     */
    private String productTypeName;

    /**
     * 产品分类名称
     */
    private String productCategoryName;

    /**
     * 产品品牌
     */
    @ExcelExport(value = "品牌",sort = 40)
    private String productBrandName;



    private Integer quantityTemp;
    private Integer quantityRepair;

    private Integer quantityRecycle;

    private Integer cabNum;

    private Integer spaceNum;



    /**
     * 产品型号
     */
    private String productModelName;

    /**
     * 适配机床
     */
    private String deviceName;

    /**
     * 市场价
     */
    private BigDecimal marketPrice;

    @ExcelExport(value = "货位容量",sort = 100)
    private Integer quantityMax;
    @ExcelExport(value = "包装单位",sort = 87)
    private String unitName;
    @ExcelExport(value = "数量（基础单位计）",sort = 88)
    private Integer quantityPack;
    @ExcelExport(value = "基础单位",sort = 90)
    private String basicsUnitName;

    private String workshopName;

    private String floor;


    //detail

    private String cabName;

    private String workshopLocation;

    private String enterpriseName;
    @ExcelExport(value = "盘验状态",sort = 110,kv = "canNotCheck-无;created-待盘验;checked-已盘验")
    private CabinetCargoSpace.CheckStatus checkStatus;


    private String checkStatusDesc;

    public String getCheckStatusDesc(){
        if (checkStatus!=null){
            return checkStatus.getDesc();
        }
        return null;
    }

    private CabinetCargoSpace.SpaceNature spaceType;

    private String spaceTypeDesc;

    public String getSpaceTypeDesc(){
        if (spaceType!=null){
            return spaceType.getDesc();
        }
        return "";
    }

    @ExcelExport(value = "规格码",sort = 30)
    private String skuSpecOld;

    private String skuCodeOld;

    private Boolean showPriceFlag=true;

    private CabinetCargoSpace.SpaceType cargoSpaceType;

    /**
     * 企业编码
     */
    private String enterpriseCode;

    private StorageInventorySpace.LoadingType loadingType;

    @Override
    public int compareTo(StorageInventorySpaceVO o) {
        if(this.quantity<o.quantity){
            return 1;
        }else if(this.quantity==o.quantity){
            if (Integer.valueOf(this.getSpaceCode())>Integer.valueOf(o.getSpaceCode())){
                return -1;
            }else{
                return 1;
            }
        }else{
            return -1;
        }
    }

    private String mainCabCode;

    private Integer quantityPackUnit;

    private Long packId;
    @ExcelExport(value = "包装规格",sort = 79)
    private String packName;
    @ExcelExport(value = "主柜编号",sort = 49)
    private String belongCabinet;
    /**
     * 物料数
     */
    private Integer skuNum;

    private Integer detailsQuantityPack;

    private Integer detailsQuantity;
    private Integer laneCapacity;
}
